<?php 
class GoodsTypeController extends Controller{
	private $db;
	//模型连接
	public function __init() {
		$this -> db = K('GoodsType');
	}
	public function index(){
		$model = $this -> db -> all();
		$this -> assign('data', $model);
		$this -> display();
	}
	//添加
	public function add(){
		if (IS_POST) {
			if ($this->db->addGoodsType()) {
				$this->success('添加成功','index');
			}else{
				$this->error($this-> db-> error);
			}
		}else{
			$this->display();
		}
	}

	//编辑
	public function edit(){
		if (IS_POST) {
			if ($this->db->editGoodsType()) {
				$this->success('编辑成功','index');
			}else{
				$this->error($this-> db-> error);
			}
		}else{
			$field = $this->db->find(Q('gtid'));
			$this->assign('field',$field);
			$this->display();
		}
	}






}


 ?>